# file_path = "pi_digits.txt"
# # with open(file_path) as file_object:
# #     for line in file_object:
# #         print(line.rstrip())
# with open(file_path) as file_object:
#     #下面这个代码的意思是将文件按照每行来读取，每行读取的结果编成列表
#     lines = file_object.readlines()
# pi_string = ""
# for line in lines:
#     pi_string += line.strip()
# print(pi_string)
# print(len(pi_string))
# p = ["abc", "kd", "heuh", "ujklif", "hjiow"]
# print(p[:4])
# filename = "programming.txt"
# with open(filename, "a") as file_object:
#     file_object.write("\ni love programming.\n")
# try:
#     print(5/0)
# except ZeroDivisionError:
#     print("you can't divide by zero!")
#所以攻击程序简而言之就是无法让程序运行，让代码报错，病毒的话应该就是篡改代码（其中某种方式）
# print("give me two numbers, and i'll divide them. ")
# print("enter 'q' to quit.")
# while True:
#     first_number = input("\nfirst number: ")
#     if first_number == 'q':
#         break
#     second_number = input("second_number: ")
#     if second_number =='q':
#         break
#     try:
#         answer = int(first_number) / int(second_number)
#     except ZeroDivisionError:
#         print("you can't divide by zero!")
#     else:
#         print(answer)
# file = "alice.txt"
# try:
#     with open(file) as file_o:
#         contents = file_o.read()
# except:
#     print("the file " + file + " has not found.")
# else:
# #按照空格拆分，长度也按照空格拆分后的单词来计算，甚至单词里面会包含标点
#     words = contents.split()
#     num_words = len(words)
#     print("the file " + file + " has about " + str(num_words) + " words.")
# def count_words(filename):
#     try:
#         with open(filename) as f:
#             contents = f.read()
#     except FileNotFoundError:
#         #print("the file " + filename + " has not found.")
#         pass
#     else:
#         words = contents.split()
#         num_words = len(words)
#         print("the file " + filename + " has about " + str(num_words) + " words.")
# filenames = ["alice.txt", "siddhartha.txt", "guest.txt"]
# for filename in filenames:
#     count_words(filename)
# import json
# numbers = [2,3,5,7,8,66]
# filename = "numbers.json"
# with open(filename) as f:
#     numbers = json.load(f)
# print(numbers)
# import json
# username = input("what's your name? ")
# filename = "username.json"
# with open(filename,"w") as f:
    # json.dump(username,f)
    # print("we'll remember you when you come back, " + username +"!")
# import json
# filename = "username.json"
# with open(filename) as f:
	# username = json.load(f)
	# print("welcome back, " + username + "!")
# import json
# def greet_user():
	# """问候用户，并指出其名字"""
	# filename = "username.json"
	# try:
		# with open(filename) as f:
			# username = json.load(f)
	# except FileNotFoundError:
		# username = input("what's your name? ")
		# with open(filename, "w") as f:
			# json.dump(username, f)
			# print("we'll remember you when you come back, " + username)
	# else:
		# print("welcome back, " + username)
# greet_user()
# import json
# def get_stored_username():
    # """如果存储了用户名，获取"""
    # filename = "username.json"
    # try:
        # with open(filename) as f:
            # username = json.load(f)
    # except FileNotFoundError:
        # return None
    # else:
        # return username
# def greet_user():
    # """问候用户，并指出起名字"""
    # username = get_stored_username()
    # if username:
        # print("welcome back, " + username)
    # else:
        # username = input("what's your name? ")
        # filename = "username.json"
        # with open(filename, "w") as f:
            # json.dump(username, f)
            # print("we'll remember you, " + username)
# greet_user()

		
